package com.study.sbsummary.service;

import com.study.sbsummary.dao.GoodsDao;
import com.study.sbsummary.model.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsDao mapper;

    @Override
    public List<Goods> listGoods() {
        return mapper.findAll();
    }

    @Override
    @Transactional
    public void addGoods(Goods goods) {
        mapper.save(goods);
    }

    @Override
    public void deleteGoods(Long id) {
        mapper.delById(id);
    }

    @Override
    public Goods selectGoodsById(Long id) {
        Goods goods = mapper.selectById(id);
        return goods;
    }
}
